package com.lcj.dr.controller;

import com.lcj.common.util.Result;
import com.lcj.dr.controller.form.DriverBaseInfoForm;
import com.lcj.dr.controller.form.DriverSettingsForm;
import com.lcj.dr.service.DriverSettingsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.HashMap;

/**
 * @Author : lcj
 * @create 2022/11/16 16:36
 */
@RestController
@RequestMapping("/settings")
@Tag(name = "SettingsController", description = "司机设置模块Web接口")
public class DriverSettingsController {
    @Resource
    private DriverSettingsService settingsService;

    @PostMapping("/searchDriverSettings")
    @Operation(summary = "查询司机的设置")
    public Result searchDriverSettings(@RequestBody @Valid DriverBaseInfoForm form) {
        HashMap map = settingsService.searchDriverSettings(form.getDriverId());
        return Result.ok().put("result", map);
    }

    @PostMapping("/updateDriverSettings")
    @Operation(summary = "更新司机设置")
    public Result updateDriverSettings(@RequestBody @Valid DriverSettingsForm form) {
        Long rows = settingsService.updateDriverSettings(form);
        return Result.ok().put("rows", rows);
    }
}